/**
 * @author liangxi
 * @since 2023/12/21
 */

#ifndef DESIGNPATTERN_CAFFEINEBEVERAGE_H
#define DESIGNPATTERN_CAFFEINEBEVERAGE_H

#include <iostream>

namespace TemplateMethod_B {

    class CaffeineBeverage {
    public:
        virtual ~CaffeineBeverage() = default;

        //使用final修饰，说明该方法是虚函数 不希望子类覆盖
        virtual void prepareRecipe() final {
            boilWater();
            brew();
            pourInCup();
            addCondiments();
        }

        virtual void brew() = 0;

        virtual void addCondiments() = 0;

        void boilWater() {
            std::cout << "Boiling water" << std::endl;
        }

        void pourInCup() {
            std::cout << "Pouring into cup" << std::endl;
        }
    };

} // TemplateMethod_B

#endif //DESIGNPATTERN_CAFFEINEBEVERAGE_H
